export const initState={
    // 初始化data
    // 购物车列表
    cartlist: [],
    // 购物车添加
    cartadd: [],
    // 购物车删除
    cartdelete: [],
    // 全选
    tag:false,
}

export const reducer=(state,action)=>{
    switch(action.type){
        // 购物车列表
        case "cartlist":
            return {
                ...state,
                cartlist:action.cartlist
            }
        // 购物车添加
        case "cartadd":
            return {
                ...state,
                cartadd:action.cartadd
            }
        // 购物车删除
        case "cartdelete":
            return {
                ...state,
                cartdelete:action.cartdelete
            }
        // 全选
        case "tag":
            return {
                ...state,
                tag:action.tag
            }
        default:
            return state;
    }
}

export const actions={
    // 修改user的action
    // 购物车列表
    changeCartlist:(cartlist)=>({type:"cartlist",cartlist}),
    // 购物车添加
    changeCartadd:(cartadd)=>({type:"cartadd",cartadd}),
    // 购物车删除
    changeCartdelete:(cartdelete)=>({type:"cartdelete",cartdelete}),
    // 全选
    allcheck:(tag)=>({type:"tag",tag}),
}